package ar.com.gestion.vistas;

import java.awt.GridLayout;
import java.awt.event.ActionListener;
import java.util.LinkedList;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JTextField;

import ar.com.gestion.GestionUtils;
import ar.com.gestion.custom.BotonCustom;
import ar.com.gestion.listeners.ListenerMedidas;
import ar.com.gestion.usuarios.CancelarListener;

public class FormAgregar extends JFrame {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	private BotonCustom aceptar;
	private JButton cancelar;
	private JTextField[] texto;

	public FormAgregar(String[] labels, ActionListener listener) {

		setLayout(new GridLayout(labels.length + 1, 2));
		texto = new JTextField[labels.length];

		for (int i = 0; i < labels.length; i++) {
			add(new JLabel(labels[i]));
			texto[i] = new JTextField();
			add(texto[i]);
		}

		aceptar = new BotonCustom("Aceptar");
		aceptar.setContext(this);
		cancelar = new JButton("Cancelar");
		add(aceptar);
		add(cancelar);
		aceptar.addActionListener(listener);
		cancelar.addActionListener(new CancelarListener(this));
		setVisible(true);

		int heigth = (labels.length * 20) + 20;
		GestionUtils.obtenerUbicacionEnPantalla(this);
		setSize(188, heigth);// el segundo la altura
	}

	public JTextField[] getTextields() {
		return texto;
	}

}
